< previous page page_686 next page >

Page 686
Get Rid of Unused Dim Statements
Suppose you wrote a function in which you use five local variables, but after a couple revisions of this function, you use only three. In this case, you should make sure you eliminate the unused Dim statements, because these take up memory at runtime. You can buy third-party tools to help you look for this type of problem.
Get Rid of Unused Declare Statements
When you use the Declare statement for a Windows API call, some additional overhead is added to your executable file. You should make sure youve only added those API calls that you actually use in your project. Eliminate any that are not used.
Eliminate Dead Code
Be sure to remove any functions and procedures youre no longer using. If you delete a control, be sure to remove any event procedures that are tied to that control. I make sure I never use an underscore character in the name of a procedure. This way, when I look in the General Declarations area of my forms, if I see a procedure with an underscore, I know its a dead event procedure thats no longer tied to a particular control.
Comments Do Not Increase Size
Comments are stripped out in the final EXE file, so use them as much as you want.
Compile to p-code Instead of Native EXE
If you compile your application to p-code instead of using a native code executable, youll find that the p-code version is about 20 percent smaller than the same native code executable. Of course, a native code executable will run a little faster, so its up to you which is more importantsize or speed.
Summary
Theres sometimes a tradeoff between the size and speed of an application. Therefore, try to keep in mind some of these optimization tricks as youre programming. They can help your program achieve its optimum performance.

 
< previous page page_686 next page >

If you like this book, buy it!